package com.tz.crm.entity;

import com.tz.crm.entity.enumeration.Level;
import com.tz.crm.entity.enumeration.Source;
import com.tz.crm.entity.enumeration.Status;
import com.tz.crm.entity.enumeration.Type;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * 客户 实体类
 */
@Entity
@Table(name = "tbl_customer")
public class Customer extends BaseEntity {

    private static final long serialVersionUID = -1634517509763085662L;

    private String name;//客户名
    private String address; //地址
    private String address2; //其他地址
    private Level level; //客户成熟度
    private Source source;//客户来源
    private String fax;//传真号
    private String webSite;//网站
    private String business;//客户行业
    private String remark;//客户描述
    private Type type;//客户类型
    private Status status;//签约与否
    private Set<VisitRecord> visitRecodeSet;//拜访记录
    private User owner;//客户所属客户专员
    private Date backSeaDate;//归还公海日期
    private String backSeaUserId;//归还公海人id

    private Contact majorContact; //主联系人

    private String provinceName;//省份名
    private String cityName;//城市名

    /**
     * 空参构造
     */
    public Customer() {
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "c_level")
    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

    @Enumerated(EnumType.STRING)
    public Source getSource() {
        return source;
    }

    public void setSource(Source source) {
        this.source = source;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getWebSite() {
        return webSite;
    }

    public void setWebSite(String webSite) {
        this.webSite = webSite;
    }

    public String getBusiness() {
        return business;
    }

    public void setBusiness(String business) {
        this.business = business;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, length = 20)
    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    @OneToMany(mappedBy = "customer")
    public Set<VisitRecord> getVisitRecodeSet() {
        return visitRecodeSet;
    }

    public void setVisitRecodeSet(Set<VisitRecord> visitRecodeSet) {
        this.visitRecodeSet = visitRecodeSet;
    }

    @Transient
    //@OneToMany(mappedBy = "customer")
    public Contact getMajorContact() {
        return majorContact;
    }

    public void setMajorContact(Contact majorContact) {
        this.majorContact = majorContact;
    }

    @OneToOne
    @JoinColumn(name = "owner_id")
    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }

    public Date getBackSeaDate() {
        return backSeaDate;
    }

    public void setBackSeaDate(Date backSeaDate) {
        this.backSeaDate = backSeaDate;
    }

    public String getBackSeaUserId() {
        return backSeaUserId;
    }

    public void setBackSeaUserId(String backSeaUserId) {
        this.backSeaUserId = backSeaUserId;
    }

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, name = "custType")
    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "name='" + name + '\'' +
                ", address='" + address + '\'' +
                ", level=" + level +
                ", source=" + source +
                '}';
    }
}
